/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
* ComPLHoodOModel.java
*
* Created on December 29, 2007, 10:39 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
 */
package gui.genomemap.outputModel;

import gui.genomemap.outputModel.options.ComPLHoodOOptionsModel;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToOne;

/**
 *
 * @author stewari1
 */
@Entity
public class ComPLHoodOModel extends OutputModel implements java.io.Serializable {

    /** Field description */
    public static final int FIG_PMAP = 0;

    /** Field description */
    public static final int FIG_FULLMAP = 1;

    /** Field description */
    private double lHood = 0.0;

    /** Field description */
    @OneToOne(cascade = CascadeType.ALL)
    private ComPLHoodOOptionsModel optionsModel = new ComPLHoodOOptionsModel();

    /**
     * Holds value of property probeSpacing.
     */
    private double[] probeSpacing;

    /** Creates a new instance of ComPLHoodOModel */
    public ComPLHoodOModel() {}

    @Override
    public int compareTo(OutputModel outputModel) {

        int superCompared = super.compareTo(outputModel);

        if ((superCompared == 0) && (outputModel instanceof ComPLHoodOModel)) {

            ComPLHoodOModel comPLHoodOModel = (ComPLHoodOModel) outputModel;
            double myLHood                  = getLHood();
            double hisLHood                 = comPLHoodOModel.getLHood();
            double diffLHood                = myLHood - hisLHood;

            return (int) ((-1.0) * diffLHood);
        }

        return superCompared;
    }

    @Override
    public int hashCode() {
        return super.hashCode() + new Double(getLHood()).hashCode();
    }

    @Override
    public boolean equals(Object obj) {

        if (obj instanceof ComPLHoodOModel) {

            ComPLHoodOModel comPLHoodOModel = (ComPLHoodOModel) obj;

            return super.equals(comPLHoodOModel) && (getLHood() == comPLHoodOModel.getLHood());
        }

        return false;
    }

    public double getLHood() {
        return lHood;
    }

    public void setLHood(double lHood) {
        this.lHood = lHood;
    }

    public ComPLHoodOOptionsModel getOptionsModel() {
        return optionsModel;
    }

    public void setOptionsModel(ComPLHoodOOptionsModel optionsModel) {
        this.optionsModel = optionsModel;
    }

    /**
     * Getter for property probeSpacing.
     * @return Value of property probeSpacing.
     */
    public double[] getProbeSpacing() {
        return this.probeSpacing;
    }

    /**
     * Setter for property probeSpacing.
     * @param probeSpacing New value of property probeSpacing.
     */
    public void setProbeSpacing(double[] probeSpacing) {
        this.probeSpacing = probeSpacing;
    }
}
